﻿using System;
using System.Collections.Specialized;
using System.IO;
using System.Security.Principal;
using System.Text;

namespace NWebMock
{
    public interface IHttpRequest
    {
        #region Properties

        /// <summary>
        /// Gets a string array of client-supported MIME accept types.
        /// </summary>
        string[] AcceptTypes { get; }

        /// <summary>
        /// Gets the anonymous identifier for the user, if present.
        /// </summary>
        string AnonymousID { get; }

        /// <summary>
        /// Gets the ASP.NET application's virtual application root path on the server.
        /// </summary>
        string ApplicationPath { get; }

        /// <summary>
        /// Gets the virtual path of the application root and makes it relative by using the tilde (~) notation for the application root (as in "~/page.aspx").
        /// </summary>
        string AppRelativeCurrentExecutionFilePath { get; }

        /// <summary>
        /// Gets information about the requesting client's browser capabilities.
        /// </summary>
        IHttpBrowserCapabilities Browser { get; }

        /// <summary>
        /// Gets the current request's client security certificate.
        /// </summary>
        IHttpClientCertificate ClientCertificate { get; }

        /// <summary>
        /// Gets or sets the character set of the entity-body.
        /// </summary>
        Encoding ContentEncoding { get; set; }

        /// <summary>
        /// Specifies the length, in bytes, of content sent by the client.
        /// </summary>
        int ContentLength { get; }

        /// <summary>
        /// Gets or sets the MIME content type of the incoming request.
        /// </summary>
        string ContentType { get; set; }

        /// <summary>
        /// Gets a collection of cookies sent by the client.
        /// </summary>
        IHttpCookieCollection Cookies { get; }

        /// <summary>
        /// Gets the virtual path of the current request.
        /// </summary>
        string CurrentExecutionFilePath { get; }

        /// <summary>
        /// Gets the virtual path of the current request.
        /// </summary>
        string FilePath { get; }

        /// <summary>
        /// Gets the collection of files uploaded by the client, in multipart MIME format.
        /// </summary>
        IHttpFileCollection Files { get; }

        /// <summary>
        /// Gets or sets the filter to use when reading the current input stream.
        /// </summary>
        Stream Filter { get; set; }

        /// <summary>
        /// Gets a collection of form variables.
        /// </summary>
        NameValueCollection Form { get; }

        /// <summary>
        /// Gets a collection of HTTP headers.
        /// </summary>
        NameValueCollection Headers { get; }

        /// <summary>
        /// Gets the HTTP data transfer method (such as GET, POST, or HEAD) used by the client.
        /// </summary>
        string HttpMethod { get; }

        /// <summary>
        /// Gets the contents of the incoming HTTP entity body.
        /// </summary>
        Stream InputStream { get; }

        /// <summary>
        /// Gets a value indicating whether the request has been authenticated.
        /// </summary>
        bool IsAuthenticated { get; }

        /// <summary>
        /// Gets a value indicating whether the request is from the local computer.
        /// </summary>
        bool IsLocal { get; }

        /// <summary>
        /// Gets a value indicating whether the HTTP connection uses secure sockets (that is, HTTPS).
        /// </summary>
        bool IsSecureConnection { get; }

        /// <summary>
        /// Gets the specified object from the QueryString, Form, Cookies, or ServerVariables collections.
        /// </summary>
        /// <param name="key">The name of the collection member to get.</param>
        string this[string key] { get; }

        /// <summary>
        /// Gets the WindowsIdentity type for the current user.
        /// </summary>
        WindowsIdentity LogonUserIdentity { get; }

        /// <summary>
        /// Gets a combined collection of QueryString, Form, Cookies, and ServerVariables items.
        /// </summary>
        NameValueCollection Params { get; }

        /// <summary>
        /// Gets the virtual path of the current request.
        /// </summary>
        string Path { get; }

        /// <summary>
        /// Gets additional path information for a resource with a URL extension.
        /// </summary>
        string PathInfo { get; }

        /// <summary>
        /// Gets the physical file system path of the currently executing server application's root directory.
        /// </summary>
        string PhysicalApplicationPath { get; }

        /// <summary>
        /// Gets the physical file system path corresponding to the requested URL.
        /// </summary>
        string PhysicalPath { get; }

        /// <summary>
        /// Gets the collection of HTTP query string variables.
        /// </summary>
        NameValueCollection QueryString { get; }

        /// <summary>
        /// Gets the raw URL of the current request.
        /// </summary>
        string RawUrl { get; }

        /// <summary>
        /// Gets or sets the HTTP data transfer method (GET or POST) used by the client.
        /// </summary>
        string RequestType { get; set; }

        /// <summary>
        /// Gets a collection of Web server variables.
        /// </summary>
        NameValueCollection ServerVariables { get; }

        /// <summary>
        /// Gets the number of bytes in the current input stream.
        /// </summary>
        int TotalBytes { get; }

        /// <summary>
        /// Gets information about the URL of the current request.
        /// </summary>
        Uri Url { get; }

        /// <summary>
        /// Gets information about the URL of the client's previous request that linked to the current URL.
        /// </summary>
        Uri UrlReferrer { get; }

        /// <summary>
        /// Gets the raw user agent string of the client browser.
        /// </summary>
        string UserAgent { get; }

        /// <summary>
        /// Gets the IP host address of the remote client.
        /// </summary>
        string UserHostAddress { get; }

        /// <summary>
        /// Gets the DNS name of the remote client.
        /// </summary>
        string UserHostName { get; }

        /// <summary>
        /// Gets a sorted string array of client language preferences.
        /// </summary>
        string[] UserLanguages { get; }

        #endregion

        #region Methods

        /// <summary>
        /// Performs a binary read of a specified number of bytes from the current input stream.
        /// </summary>
        /// <param name="count">The number of bytes to read.</param>
        /// <returns>A byte array.</returns>
        byte[] BinaryRead(int count);

        /// <summary>
        /// Maps an incoming image-field form parameter to appropriate x-coordinate and y-coordinate values.
        /// </summary>
        /// <param name="imageFieldName">The name of the form image map.</param>
        /// <returns>A two-dimensional array of integers.</returns>
        int[] MapImageCoordinates(string imageFieldName);

        /// <summary>
        /// Maps the specified virtual path to a physical path.
        /// </summary>
        /// <param name="virtualPath">The virtual path (absolute or relative) for the current request.</param>
        /// <returns>The physical path on the server specified by virtualPath.</returns>
        string MapPath(string virtualPath);

        /// <summary>
        /// Maps the specified virtual path to a physical path.
        /// </summary>
        /// <param name="virtualPath">The virtual path (absolute or relative) for the current request.</param>
        /// <param name="baseVirtualDir">The virtual base directory path used for relative resolution.</param>
        /// <param name="allowCrossAppMapping">true to indicate that virtualPath may belong to another application; otherwise, false.</param>
        /// <returns>The physical path on the server.</returns>
        string MapPath(string virtualPath, string baseVirtualDir, bool allowCrossAppMapping);

        /// <summary>
        /// Saves an HTTP request to disk.
        /// </summary>
        /// <param name="filename">The physical drive path.</param>
        /// <param name="includeHeaders">A Boolean value specifying whether an HTTP header should be saved to disk.</param>
        void SaveAs(string filename, bool includeHeaders);

        /// <summary>
        /// Causes validation to occur for the collections accessed through the Cookies, Form, and QueryString properties.
        /// </summary>
        void ValidateInput();

        #endregion
    }
}
